package com.xyazm.order.statemachine.action.order.create.node;

import com.xyazm.order.domain.dto.OrderInfoDTO;
import com.xyazm.order.domain.mq.OrderPaymentDelayDTO;
import com.xyazm.order.service.IMqMessageService;
import com.xyazm.process.engine.process.ProcessContext;
import com.xyazm.process.engine.process.StandardProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 发送超时取消MQ信息节点
 * @author xuyou
 * @date 2023年02月02日 21:14
 */
@Component
public class CreateOrderSendPayTimeoutDelayMessageNode extends StandardProcessor {

    @Autowired
    private IMqMessageService mqMessageService;

    @Override
    protected void processInternal(ProcessContext context) {
        OrderInfoDTO orderInfoDTO = context.get("orderInfoDTO");
        OrderPaymentDelayDTO orderPaymentDelayDTO = new OrderPaymentDelayDTO();
        orderPaymentDelayDTO.setOrderId(orderInfoDTO.getOrderId());
        // 发送订单超时未支付消息
        mqMessageService.sendOrderPayTimeoutDelayMessage(orderPaymentDelayDTO);
    }
}
